
import { Component, Input, ChangeDetectorRef, OnInit, ViewChild } from '@angular/core';
import { RouteGuard } from '../../guards/route.guard';
import { StorageService } from '../../shared/services/storage.service';
import { Profile } from '../login/models/profile.model';
import { BaseComponent } from '../../shared/components/baseComponent/base.component';
import { SearchType } from '../../shared/components/search/search.service';
import { ModalComponent } from '../../shared/components/modal/modal.component';
import { CompanyService } from '../../modules/research/company/company.service';

/**
 * Navigation main component
 *
 * Author: Sorin Spiru
 * Date: 13.01.2018
 */
@Component({
   moduleId: module.id,
   templateUrl: 'navigation.component.html',
   selector: 'nav-menu',
   styleUrls: ['./navigation.component.scss']
})
export class NavComponent extends BaseComponent implements OnInit {
    @Input() routes: any[];
    @Input() menuLevel: number;

    public searchType: SearchType = SearchType.company;

    public user: Profile = StorageService.get().userInfo;

    public activeRoute = RouteGuard.canActivate;
    public managerEmail: string;

    constructor (
        private cdRef: ChangeDetectorRef,
        private companyService: CompanyService
    ) {
        super(cdRef);

    }

    ngOnInit() {
        const userInfo = StorageService.get().userInfo;
        this.managerEmail = userInfo.accountManagerEmail;
    }

    /* todo: move this user model */
    get userInitials(): string {
        return `${this.user.firstName.charAt(0)}${this.user.lastName.charAt(0)}`;
    }  
}
